#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : aimix
@File    : merge_audio_worker.py
@IDE     : PyCharm
@Author  : admin
@Date    : 2025/4/22 09:52
"""


import traceback
from PyQt5.QtCore import pyqtSignal, QThread
from core.audio.merge_audio import AudioMerger


class MergeAudioWorker(QThread):
    """合并音频线程"""
    failed = pyqtSignal(Exception)

    def __init__(self, input_files, output_folder, parent=None):
        super(MergeAudioWorker, self).__init__()
        self.input_files = input_files
        self.output_folder = output_folder

    def run(self):
        try:
            merger = AudioMerger(self.input_files, self.output_folder)
            merger.merge_audio()
        except Exception as e:
            self.failed.emit(e)
            traceback.print_exc()